
#ifndef dex_format_h
#define dex_format_h
#include "dex-structs.h"


class CDexFile
{
public:
	CDexFile():pFileBase(NULL),length(0) {}
	CDexFile(char*p,int size):pFileBase(p),length(size) {}	
	

	CDexHeaderItem *GetHeader()
	{return (CDexHeaderItem *)(pFileBase);}

	CDexStringidItem *GetStringIds()
	{return (CDexStringidItem *)(pFileBase+GetHeader()->string_ids_off);}

	ubyte* GetStringIdsAddr()
	{return (ubyte *)(pFileBase+GetHeader()->string_ids_off);}
	int GetStringIdsSize(){return GetHeader()->string_ids_size;}

	CDexTypeidItem *GetTypeIds()
	{return (CDexTypeidItem *)(pFileBase+GetHeader()->type_ids_off);}

	ubyte* GetTypeIdsAddr()
	{return (ubyte *)(pFileBase+GetHeader()->type_ids_off);}
	int GetTypeIdsSize(){return GetHeader()->type_ids_size;}

	CDexProtoidItem *GetProtoIds()
	{return (CDexProtoidItem *)(pFileBase+GetHeader()->proto_ids_off);}

	ubyte* GetProtoIdsAddr()
	{return (ubyte *)(pFileBase+GetHeader()->proto_ids_off);}
	int GetProtoIdsSize(){return GetHeader()->proto_ids_size;}

	CDexFieldidItem *GetFieldIds()
	{return (CDexFieldidItem *)(pFileBase+GetHeader()->field_ids_off);}

	ubyte* GetFieldIdsAddr()
	{return (ubyte *)(pFileBase+GetHeader()->field_ids_off);}
	int GetFieldIdsSize(){return GetHeader()->field_ids_size;}

	CDexMethodidItem *GetMethodIds()
	{return (CDexMethodidItem *)(pFileBase+GetHeader()->method_ids_off);}

	ubyte* GetMethodIdsAddr()
	{return (ubyte *)(pFileBase+GetHeader()->method_ids_off);}
	int GetMethodIdsSize(){return GetHeader()->method_ids_size;}

	CDexClassdefItem *GetClassDefs()
	{return (CDexClassdefItem *)(pFileBase+GetHeader()->class_defs_off);}

	ubyte* GetClassDefsAddr()
	{return (ubyte *)(pFileBase+GetHeader()->class_defs_off);}
	int GetClassDefsSize(){return GetHeader()->class_defs_size;}

	ubyte *GetData()
	{return (ubyte *)(pFileBase+GetHeader()->data_off);}

	ubyte* GetDataAddr()
	{return (ubyte *)(pFileBase+GetHeader()->data_off);}
	int GetDataSize(){return GetHeader()->data_size;}

	ubyte *GetLinkData()
	{return (ubyte *)(pFileBase+GetHeader()->link_off);}

	ubyte* GetLinkDataAddr()
	{return (ubyte *)(pFileBase+GetHeader()->link_off);}
	int GetLinkDataSize(){return GetHeader()->link_size;}

	CDexMapList *GetMapist()
	{return (CDexMapList *)(pFileBase+GetHeader()->map_off);}
	void print();
	int sprint(char *);
protected:
	char *pFileBase;
	int length;
};

#endif// dex_format_h
	
